package demo1;

class NameExpection extends  Exception{
    public NameExpection(String message) {
        super(message);
    }
}
class PassWordExpection extends  Exception{
    public PassWordExpection(String message){
        super(message);
    }
}
public class Login {
    private String name="zhnagsan";
    private String password="123456";

    public void LogIn(String name,String password) throws NameExpection,PassWordExpection{
        if(!this.name.equals(name)){
            throw new NameExpection("用户名错误");
        }
        if(!this.password.equals(password)){
            throw new PassWordExpection("密码错误");
        }
        System.out.println("登录成功");
    }
    public static void main(String[] args) throws NameExpection,PassWordExpection{
        Login login=new Login();
        try{
            login.LogIn("lisi","52364");
        }catch (NameExpection e){
            e.printStackTrace();
        }catch (PassWordExpection e){
            e.printStackTrace();
        }
    }
}
